package com.itheima.controller;

import com.itheima.jopo.AliOSSUtils;
import com.itheima.jopo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * FileController
 *
 * @author liliudong
 * @version 1.0
 * @description
 * @date 2023/4/30 10:49
 */
@Slf4j
@RestController
public class FileController {

    @Autowired
    private AliOSSUtils aliOSSUtils;

    // 方法 post
    // MultipartFile
    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws IOException {
        log.info("文件已经接收到了，我下节课学处理");
        String upload = aliOSSUtils.upload(image);
        return Result.success(upload);
    }

}
